﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>特定考试成绩导入</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../static/css/font.css">
    <link rel="stylesheet" href="../../../static/css/weadmin.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <div class="weadmin-nav">
        <span class="layui-breadcrumb" style="visibility: visible;">
            <a href="#">首页</a><span lay-separator="">/</span>
            <a href="#">考试管理</a><span lay-separator="">/</span>
            <a><cite>特定考试成绩导入</cite></a>
        </span>
        <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">&#x1002;</i>
        </a>
    </div>
    <div class="weadmin-body">
        <div class="layui-row layui-form">
            用户名：
            <div class="layui-inline">
                <input type="text" id="UserID" placeholder="用户名" autocomplete="off" class="layui-input">
            </div>
            考试开始时间：
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="start" placeholder="yyyy-MM-dd">
            </div>
            -
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="end" placeholder="yyyy-MM-dd">
            </div>
            <button class="layui-btn" id="sreach"><i class="layui-icon">&#xe615;</i></button>
        </div>
        <table id="datalist" lay-filter="datalist"></table>
    </div>
    <script src="../../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/html" id="toolbar">
        <div class="layui-btn-container">
            <!--<button class="layui-btn layui-btn-sm" lay-event="delAll"><i class="layui-icon"></i>批量删除</button>--><!--功能没做，先隐藏-->
            <!--<button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon"></i>添加</button>-->
            <button class="layui-btn layui-btn-sm" lay-event="upload"><i class="layui-icon"></i>批量上传</button>
        </div>
    </script>
    <script type="text/html" id="tool">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script>
        layui.use(['form', 'table', 'laydate', 'jquery', 'layer'], function () {
            var form = layui.form,
                table = layui.table,
                laydate = layui.laydate,
                $ = layui.jquery,
                layer = layui.layer;
            $.support.cors = true;
            $.ajaxSetup({
                cache: false,
                headers: {
                    "userid": JSON.parse(window.localStorage.authInfo).UserId,
                    "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                },
            })
            //执行一个laydate实例
            laydate.render({
                elem: '#start',
                trigger: 'click'
            });
            //执行一个laydate实例
            laydate.render({
                elem: '#end',
                trigger: 'click'
            });
            function showList() {
                var swhere = "",
                    UserID = $("#UserID").val().trim(),
                    StartDateTime = $("#start").val(),
                    EndDateTime = $("#end").val();
                //swhere = "(StartExamDateTime>'" + StartDateTime + "'" + " and EndExamDateTime<'" + EndDateTime + ")";
                if (UserID != "") { swhere += " and T.UserID='" + UserID + "' " }
                if (StartDateTime != "") { swhere += " and ExamDateTime>='" + StartDateTime + "' " }
                if (EndDateTime != "") { swhere += " and ExamDateTime<='" + EndDateTime + "' " }

                table.render({
                    id: "datalist",
                    elem: '#datalist',
                    url: ApiUrl + 'SpecialExamScore/SelListPage', //数据接口,
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    where: { swhere: swhere },
                    cellMinWidth: 80,
                    limit:30,
                    toolbar: "#toolbar",
                    cols: [
                        [
                            { type: 'checkbox' },
                            { field: 'UserID', title: '工号' ,width:120}, 
                            { field: 'UserName', title: '姓名', width: 120 },
                            { field: 'DepName', title: '部门', width: 300 },
                            { field: 'PaperName', title: '试卷名称', width: 220},
                            { field: 'PaperType', title: '试卷类型', width: 100}, 
                            { field: 'ExamDateTime', title: '考试时间',width:160 }, 
                            { field: 'Score', title: '分数', width: 80}
                        ]
                    ],
                    parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    done: function (res, curr, count) {
                        //如果是异步请求数据方式，res即为你接口返回的信息。
                        //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                    },
                    event: true,
                    page: true
                });
            }
            //监听事件
            table.on('toolbar(datalist)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'upload':
                        var upload = layer.open({
                            type: 2,
                            title: "试题上传",
                            area: ['500px', '300px'],
                            fixed: false, //不固定
                            maxmin: true,
                            content: './specialexamscoreinfo_upload.html',
                            end: function () {
                                location.reload();
                            }
                        });
                        //layer.full(upload);
                        break;
                };
            });
            $(function () {
                showList();
                $("#sreach").click(function () {
                    showList();
                })
            })
        });
    </script>
</body>
</html>